﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace MugenInjection.Interface
{
    /// <summary>
    /// Provides a path to register bindings.
    /// </summary>
    public interface IInjectorBinder : IDisposableObject
    {
        /// <summary>
        /// Gets the collection of all bindings for the current <see cref="IInjectorBinder"/>.
        /// </summary>
        IBindingCollection Bindings { get; }

        /// <summary>
        /// Creates the <see cref="IBindingContext"/> for the current <see cref="IInjectorBinder"/>.
        /// </summary>
        /// <param name="service">The specifed service <see cref="Type"/>.</param>
        /// <param name="member">The specified <see cref="MemberInfo"/> when injected specified service. Can be null.</param>
        /// <param name="parameterInfo">The specified <see cref="ParameterInfo"/> when injected specified service.</param>
        /// <param name="parameters">The specified parameters for service.</param>
        /// <param name="specialParameters">The special parameters for resolve specified service.</param>
        /// <returns>An instance of <see cref="IBindingContext"/>.</returns>
        IBindingContext CreateBinderContext(Type service, MemberInfo member, ParameterInfo parameterInfo,
                                            IEnumerable<IInjectionParameter> parameters,
                                            IDictionary<string, object> specialParameters);

        /// <summary>
        /// Adds the specified <see cref="IBinding"/>.
        /// </summary>
        /// <param name="binding">The specified <see cref="IBinding"/>.</param>
        void AddBinding(IBinding binding);

        /// <summary>
        /// Removes the specified <see cref="IBinding"/>.
        /// </summary>
        /// <param name="binding">The specified <see cref="IBinding"/>.</param>
        bool RemoveBinding(IBinding binding);

        /// <summary>
        /// Gets all binding for tne specified service <see cref="Type"/>.
        /// </summary>
        /// <param name="service">The specified service <see cref="Type"/>.</param>
        /// <returns>A series of bindings that are registered for the service.</returns>
        IEnumerable<IBinding> GetBindings(Type service);

        /// <summary>
        /// Gets all binding for the specified <see cref="IBindingContext"/>.
        /// </summary>
        /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
        /// <returns>A series of bindings that are registered for the <see cref="IBindingContext"/>.</returns>
        IEnumerable<IBinding> GetBindings(IBindingContext bindingContext);
    }
}